package com.lxh.lxhcrm.controller.aftersale;

import ch.qos.logback.core.net.SyslogOutputStream;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.lxh.lxhcrm.model.pojos.ServeRecord;
import com.lxh.lxhcrm.model.pojos.ServeType;
import com.lxh.lxhcrm.model.service.AfterSaleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 开发团队 ：lxh
 * 开发人员 ：李兴洋
 * 开发时间 ：2020年3月10日18:57:37
 * 类的名称 ：CustomerServiceController
 * 类的描述 ：售后模块中的客户服务
 */
@RestController
@RequestMapping("/after-sale/customer-service")
public class CustomerServiceController {
    @Autowired
    AfterSaleService afterSaleService;

    //客户服务集合
    @RequestMapping("/service-list")
    public Map<String, Object> serviceList(Integer page , Integer size , String search , String kcName){
        Page<Object> obj = PageHelper.startPage(page, size);
        List<ServeRecord> allCusService = afterSaleService.findAllCusService(search, kcName);
        Map<String,Object> kMap = new HashMap<>();
        kMap.put("total",obj.getTotal());
        kMap.put("rows",allCusService);
        return kMap;
//        System.out.println("1=>"+page);
//        System.out.println("1=>"+size);
//        System.out.println("1=>"+search);
//        System.out.println("1=>"+kcName);
    }

    /** 新增客户服务  **/
    @RequestMapping("/add-service")
    @ResponseBody
    public void addCusService(@RequestBody ServeRecord customerService){
        afterSaleService.addCusService(customerService);
    }

    /** 删除客户服务  **/
    @RequestMapping("/delete-cusServe")
    @ResponseBody
    public void deleteCusServe(Integer csNo){
        afterSaleService.deleteServeRecord(csNo);
    }

    //审批
    @RequestMapping("/serveCheck")
    @ResponseBody
    public void serveCheck(Integer serveId){
        afterSaleService.serveCheck(serveId);
    }

    /** 所有客户服务状态**/
    @RequestMapping("/serveTypeList")
    public List<ServeType> allServeType(){
        return afterSaleService.findAllServeType();
    }

    /** 添加客户服务状态**/
    @RequestMapping("/add-serveType")
    @ResponseBody
    public void addServeType (ServeType st){
        afterSaleService.addServeType(st);
    }

    /** 删除客户服务状态**/
    @RequestMapping("/delete-serveType")
    @ResponseBody
    public void deleteServeType(Integer stId){
        afterSaleService.deleteServeType(stId);
    }

}
